package cn.eonshine.base.core.util;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 
 * @ClassName: ProfileUtil
 * @Description: generate long number <br>
 *               "https://blog.csdn.net/cyxinda/article/details/78254055"
 * @author: Alan
 * @date: 2019-02-26 22:40:46
 * 
 */
public class ProfileUtil {
	
	private static AtomicInteger counter = new AtomicInteger(0);

	/**
	 * get id number
	 * 
	 * @return
	 */
	public static Long getAtomicCounter() {
		if (counter.get() > 999999) {
			counter.set(1);
		}
		long time = System.currentTimeMillis();
		long returnValue = time * 100 + counter.incrementAndGet();
		return returnValue;
	}

	private static long incrementAndGet() {
		return counter.incrementAndGet();
	}

	public static void main(String[] args) {
		System.out.println(ProfileUtil.getAtomicCounter());
	}
}
